#!/bin/bash
current_dir=$(pwd)
case $# in
    # 仅查看一次
    1)
	rm -f $current_dir/layer_detail.txt
	adb shell dumpsys SurfaceFlinger | grep -iA 200 'HWC Layers' | grep -iB 200 'buffer_id:' >> $current_dir/layer_detail.txt
	adb shell dumpsys SurfaceFlinger | grep -iA 200 'Output Layer' | grep -iB 200 'SurfaceFlinger global state:' >> $current_dir/layer_detail.txt
	glogg $current_dir/layer_detail.txt
        ;;
    # 无限查看
    2)
	while true;do adb shell dumpsys SurfaceFlinger | grep -iA 200 'HWC Layers' | grep -iB 200 'buffer_id:';done;
        ;;
    *)
        echo "错误: 传入参数过多"
        exit 1
        ;;
esac
